<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>支出</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" type="text/css" href="<%=basePath %>/pages/manage/css/bootstrap.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath %>/pages/manage/css/bootstrap-responsive.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath %>/pages/manage/css/style.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath %>/pages/manage/css/sweetalert.css">
	<link rel="stylesheet" type="text/css" href="<%=basePath %>/pages/manage/css/pages.css">
	
	<script type="text/javascript" src="<%=basePath %>/pages/manage/js/jquery-1.7.2.min.js"></script> 
	<script type="text/javascript" src="<%=basePath %>/pages/manage/js/bootstrap.js"></script>
	<script type="text/javascript" src="<%=basePath %>/pages/manage/js/ckform.js"></script>
	<script type="text/javascript" src="<%=basePath %>/pages/manage/js/common.js"></script>
	<script src="<%=basePath %>pages/manage/js/sweetalert.min.js"></script> 
	<style type="text/css">
	#upload_fr{
		border:0px;
	}
	</style>
	<style type="text/css">
		body {font-size: 14px;
			padding-bottom: 40px;
			background-color: #e9e7ef;
		}
		.sidebar-nav {
			padding: 9px 0;
		}
		@media ( max-width : 980px) {
			/* Enable use of floated navbar text */
			.navbar-text.pull-right {
				float: none;
				padding-left: 5px;
				padding-right: 5px;
			}
		}
	</style>
	<script type="text/javascript">
		function showUpdate(id){
			 location.href="<%=basePath %>/pages/payOutForm.jsp?id="+id;
		 }
		function deleteUser(id){
			swal({
				title: "确认删除吗?",
				text: "您将要删除一条数据!",
				type: "warning",
				showCancelButton: true,
				confirmButtonColor: '#0000ff',
				confirmButtonText: '是的,我确认删除!',
				cancelButtonText: '取消',
				closeOnConfirm: false
			},
			function(){
				var url = "payOut/delete?payoutId="+id+"&usName=${name}";
				$.post(url,null,function(d){
					if(d=="ok"){
						swal("删除成功!", "恭喜您,成功删除了一条记录!", "success");
						setTimeout("location.reload()",2000) ;//重新加载一次当前页面
					}else{
						swal("删除失败!", "对不起,未能删除,可能是有下级类型!", "error");
					}
				});
			});
			
			
		}
	</script>
  </head>
  
  <body>
    	<form class="form-inline definewidth m20" action="payOut/list?userId=${name}" method="post">
		 <font color="#777777"><strong>支出时间：</strong></font> 
		 <input type="text" name="name" id="name" class="abc input-default" placeholder="" value="${date}">&nbsp;&nbsp;
		 <input type="hidden" id="usName" name="usName" value="${name}"/>
		<button type="submit" class="btn btn-primary">查询</button>
		&nbsp;&nbsp;
		<a class="btn btn-primary" href="<%=basePath %>/pages/payOutForm.jsp">添加 </a>
 			
	</form>
		<div  style="width:1000px;position: absolute; left:130px;">
    	<table class="table table-bordered table-hover definewidth m10">
	    	<thead>
	    		<tr style="background-color: #638cd8;">
	    			<td>支出名称</td>
	    			<td>支出金额</td>
	    			<td>支出时间</td>
	    			<td>操作</td>
	    		</tr>
	    	</thead>
    		<c:forEach items="${list}" var="payOut">
    			<tr>
    			<td>${payOut.payoutName }</td>
    			<td>${payOut.payoutMoney }</td>
    			<td>${payOut.payoutDate }</td>
    			<td style="text-align: center;line-height: 40px;"><a href="javascript:showUpdate('${payOut.payoutId }');" class="btn btn-primary">修改</a> &nbsp;
					<a href="javascript:deleteUser('${payOut.payoutId }')" class="btn btn-primary">删除</a>
				</td>
    			</tr>
    		</c:forEach>
    	</table>
    	<ul id="menu">
			<li><a href="javascript:previousPage('${page.pages-1}');">上一页</a></li>
			<c:forEach begin="1" end="${page.totalPages}" var="s">
				<c:if test="${page.pages==s}">
					<li><a href="payOut/list?pages=${s}&userId=${name}" style="background: #adadad">${s}</a></li>
				</c:if>
				<c:if test="${page.pages != s}">
		  	 	 	<li><a href="payOut/list?pages=${s}&userId=${name}" >${s }</a></li>
		  		</c:if>
			</c:forEach>
			<li><a href="javascript:nextPage('${page.pages+1}');">下一页</a></li>
		</ul>
    </div>
    <script type="text/javascript">
    	var name = "${name}";
		/**
		下一页
		*/
	 	function nextPage(p){
		 	var total = "${page.totalPages}" ;
		 	if(p<=total){
		 		location.href="payOut/list?pages="+p+"&userId="+name ;
		 		
			}else{
				swal("对不起,已经是最后一页了!");
			}
		}

	 	/**
		上一页
		*/
		function previousPage(p){
			if(p<=0){
				swal("对不起,已经是第一页!");
			}else{
				location.href="payOut/list?pages="+p+"&userId="+name ;
			}
		}
	 </script>
	 
  </body>
</html>
